package cn.xd.base.persistence.mps.impl;

import cn.hutool.core.util.ObjUtil;
import cn.xd.base.persistence.dos.AdminOrgDO;
import cn.xd.base.persistence.mapper.AdminOrgMapper;
import cn.xd.base.persistence.mps.AdminOrgMpService;
import cn.xd.common.enums.common.CommonStatusEnum;
import cn.xd.core.response.ObjectResult;
import cn.xd.core.service.impl.BasicMpServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;

@Service
public class AdminOrgMpServiceImpl extends BasicMpServiceImpl<AdminOrgMapper, AdminOrgDO> implements AdminOrgMpService {

    @Override
    public ObjectResult<AdminOrgDO> getAdminOrg(String name, Long parentId, Long neId) {
        return getOneForLimitOneResult(Wrappers.lambdaQuery(AdminOrgDO.class)
                .ne(ObjUtil.isNotNull(neId), AdminOrgDO::getId, neId)
                .eq(AdminOrgDO::getName, name).eq(AdminOrgDO::getParentId, parentId)
                .ne(AdminOrgDO::getStatus, CommonStatusEnum.DELETED.getCode()));
    }
}
